package designmodel.oberver;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public abstract class Observable {

	List<Observer> observers = new ArrayList<Observer>();
	
	public void addObserver(Observer observer){
		observers.add(observer);
	}
	
	public void removeObserver(Observer observer){
		observers.remove(observer);
	}
	public void notifyObservers(Object value){
		Iterator<Observer> it = observers.iterator();
		while(it.hasNext()){
			Observer observer = (Observer)it.next();
			observer.update(this, value);
		}
	}
}
